package club.cearnach.security.provider.impl;

import club.cearnach.security.enumeration.RoleEnum;
import club.cearnach.security.provider.AuthorizeConfigProvider;
import org.springframework.security.config.annotation.web.builders.HttpSecurity;
import org.springframework.security.config.annotation.web.configurers.ExpressionUrlAuthorizationConfigurer;
import org.springframework.stereotype.Component;

/**
 * @author 阮胜
 * @date 2018/5/23 14:23
 */
@Component
public class AdminAuthorizeConfigProvider implements AuthorizeConfigProvider {
    @Override
    public void configure(ExpressionUrlAuthorizationConfigurer<HttpSecurity>.ExpressionInterceptUrlRegistry config) {
        config.antMatchers("/admin/**").hasRole(RoleEnum.ADMIN.getRole());
    }
}
